import 'react-native-gesture-handler';//一定要在首行，官网https://reactnavigation.org/docs/getting-started
import React from 'react';
import { Provider } from 'react-redux';
import store from '../store/configureStore';
import { createAppContainer } from 'react-navigation';//以前版本【2.x】createStackNavigator和createBottomTabNavigator这引入，现在4.x版本需要下载依赖包在依耐包引入不能直接在此位置引入会报错`createStackNavigator()` has been moved to `react-navigation-stack`...4.x版本不要加载jetfer.会报错
import {StyleSheet,PixelRatio,Dimensions} from 'react-native';

import { createStackNavigator } from 'react-navigation-stack';
import {TabNav} from "./RootPage";
import LoginPage from "./page/Login/loginPage";
import RegPage from "./page/Login/regPage";
import FindAccountPage from "./page/Login/FindAccountPage"; // 
import HomePage from './page/Home/HomePage';
import FriendPage from './page/Friend/FriendPage';
import TaskPage from './page/Task/TaskPage';
import MinePage from './page/Mine/MinePage';
import DealPage from './page/Deal/DealPage';

const dp2px = dp=>PixelRatio.getPixelSizeForLayoutSize(dp);
const px2dp = px=>PixelRatio.roundToNearestPixel(px);

let designSize = {width:1920,height:1080};

let pxRatio = PixelRatio.get();
const win_width = Dimensions.get('window').width;
const win_height = Dimensions.get('window').height;

let width= dp2px(win_width);
let height = dp2px(win_height);
console.log(pxRatio,win_width,win_height,width,height)
let design_scale = designSize.width/width;
height = height*design_scale

let scale = 1/pxRatio/design_scale;

const App = createStackNavigator({//StackNavigator()有些版本直接用这个使用它但是4版本需要createStackNavigator创建后结合createAppContainer一起使用才可以。//用于配置栈管理的页面
        Login: {screen: LoginPage}, // 登录页
        Reg: {screen: RegPage}, // 注册页
        FindAccount: {screen: FindAccountPage}, // 找回密码页
        // Main: {
        //     screen: TabNav,
        //     navigationOptions: ({navigation}) => ({
        //         headerShown: false
        //     })
        // }
        Home: {
            screen: HomePage,//可以是几个页面组合的大组件const HomePage = createTabNavigator({Tab1: Good, Tab2: Share,  });，表示home的tab栏目里面好几个转换子页面。4.x版本写法查资料不明
        },
        Task: {
            screen: TaskPage,//播放视频界面
        },
        Friend: {
            screen: FriendPage,//导出答题pdf
        },
        Deal: {
            screen: DealPage,//答题结算
        },
        Mine: {
            screen: MinePage,
        }
    },
    {
        initialRouteName: 'Home',////这个设置是初始化设置 初始化显示modul
        headerMode: 'screen'
    });
    const Container = createAppContainer(App);
    class Apps extends React.Component{
        render() {
            return (
                <Provider store={store} >
                    <Container  />
                </Provider>
            );
        }
    };
    const styles = StyleSheet.create({
        a:{
            width: width,
            height: height,
            transform: [{translateX: -width * .5}, {translateY: -height * .5}, {scale: scale}, {translateX: width * .5}, {translateY: height * .5}],
                    
        }

    })
export default Apps;